#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QToolBar>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QToolBar* tb1 = new QToolBar();
    QToolBar* tb2 = new QToolBar();

    QAction* act1 = new QAction("动作1");
    QAction* act2 = new QAction("动作2");
    QAction* act3 = new QAction("动作3");
    QAction* act4 = new QAction("动作4");

    tb1->addAction(act1);
    tb1->addAction(act2);
    tb2->addAction(act3);
    tb2->addAction(act4);

    this->addToolBar(tb1);
    this->addToolBar(Qt::LeftToolBarArea ,tb2);
    // 只允许在左右侧停靠
    tb1->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
    tb1->setFloatable(false);
    tb1->setMovable(false);
}

MainWindow::~MainWindow()
{
    delete ui;
}

